/*
 * Copyright (C) 2019-2020 Alibaba Group Holding Limited
 */

#ifndef __DRV_DISPLAY_H__
#define __DRV_DISPLAY_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <devices/device.h>
#include <devices/driver.h>

typedef struct {
    void    *dev_comm;          // device for screen communication
    int     enable_pin;         // enable line pin
    int     ncol;               // number of columns
    int     nrow;               // number of rows
    int     brightness;         // screen brightness
    uint8_t *matrix_map;        // screen matrix mapping of register address
    uint8_t *extled_map;        // extern led mapping of register address
    int     extled_num;
} mdisplay_config_t;

typedef struct mdisplay_driver {
    driver_t drv;
    int (*enable)(aos_dev_t *dev);
    int (*disable)(aos_dev_t *dev);
    int (*config)(aos_dev_t *dev, mdisplay_config_t *config);      // config communication device and sdb line
    int (*set_brightness)(aos_dev_t *dev, int brightness);          // brightness 0 ~ 100
    int (*show)(aos_dev_t *dev, uint8_t *buf, size_t len);
    int (*extled_set)(aos_dev_t *dev, uint8_t idx, uint8_t val);
} mdisplay_driver_t;

#define mdisplay_open(name) device_open(name)
#define mdisplay_open_id(name, id) device_open_id(name, id)
#define mdisplay_close(dev) device_close(dev)

int mdisplay_config(aos_dev_t *dev, mdisplay_config_t *config);
int mdisplay_enable(aos_dev_t *dev);
int mdisplay_disable(aos_dev_t *dev);
int mdisplay_set_brightness(aos_dev_t *dev, int brightness);
int mdisplay_show(aos_dev_t *dev, uint8_t *buf, size_t len);

int mdisplay_extled_set(aos_dev_t *dev, uint8_t idx, uint8_t val);


#ifdef __cplusplus
}
#endif

#endif
